/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mycompany.moviedownloader.DbModel;

import static com.mycompany.moviedownloader.DbModel.Format.getType;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 *
 * @author patrik
 */
public class Genre {
    
    private static final Map<String, Integer> ciselnik;
    
    static {
        Map<String, Integer> tmp = new HashMap<>();

        tmp.put("Akční", 1);
        tmp.put("Animovaný", 2);
        tmp.put("Dobrodružný", 3);
        tmp.put("Dokumentární", 4);
        tmp.put("Drama", 5);
        tmp.put("Erotický", 6);
        tmp.put("Experimentální", 7);
        tmp.put("Fantasy", 8);
        tmp.put("Film-Noir", 9);
        tmp.put("Historický", 10);
        tmp.put("Horor", 11);
        tmp.put("Hudební", 12);
        tmp.put("IMAX", 13);
        tmp.put("Katastrofický", 14);
        tmp.put("Komedie", 15);
        tmp.put("Krátkometrážní", 16);
        tmp.put("Krimi", 17);
        tmp.put("Loutkový", 18);
        tmp.put("Muzikál", 19);
        tmp.put("Mysteriózní", 20);
        tmp.put("Podobenství", 21);
        tmp.put("Poetický", 22);
        tmp.put("Pohádka", 23);
        tmp.put("Povídkový", 24);
        tmp.put("Psychologický", 25);
        tmp.put("Publicistický", 26);
        tmp.put("Reality-TV", 27);
        tmp.put("Road", 28);
        tmp.put("Rodinný", 29);
        tmp.put("Romantický", 30);
        tmp.put("Sci-Fi", 31);
        tmp.put("Soutěžní", 32);
        tmp.put("Sportovní", 33);
        tmp.put("Talk-show", 34);
        tmp.put("Telenovela", 35);
        tmp.put("Thriller", 36);
        tmp.put("Válečný", 37);
        tmp.put("Western", 38);
        tmp.put("Životopisný", 39);

        ciselnik = Collections.unmodifiableMap(tmp);
    }

    public static Integer getGenre(String genre) {
        return ciselnik.get(genre);
    }
    
    private final Integer value;
    
    public Genre(String movieType){
        value = getGenre(movieType);
    }
    
    public Genre(Integer type){
        value = type;
    }
    
    public Integer getValue(){
        return this.value;
    }
    
    @Override
    public String toString(){
        for(String str : ciselnik.keySet()){
            if(ciselnik.get(str) == value){
                return str;
            }
        }
        return null;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 97 * hash + Objects.hashCode(this.value);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Genre other = (Genre) obj;
        if (!Objects.equals(this.value, other.value)) {
            return false;
        }
        return true;
    }
    
    
    
}
